<html>
<head><meta charset="utf-8"><title>Sized is not an autotrait · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html">Sized is not an autotrait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232282550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232282550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232282550">(Mar 29 2021 at 15:01)</a>:</h4>
<p>I have the following snippet:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Node</span><span class="o">&lt;</span><span class="n">C</span>: <span class="nc">CollectionFactory</span><span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">children</span>: <span class="nc">C</span>::<span class="n">Collection</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">CollectionFactory</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Collection</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">CollectionFactory</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Collection</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Collection</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span>: <span class="nb">Sized</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">push</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">v</span>: <span class="nc">T</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Collection</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">push</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">v</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Node</span>::<span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">children</span>: <span class="nb">Vec</span>::<span class="n">new</span><span class="p">(),</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="232282681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232282681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232282681">(Mar 29 2021 at 15:02)</a>:</h4>
<p>this currently fails to compile with the following error:</p>
<div class="codehilite"><pre><span></span><code>error[E0275]: overflow evaluating the requirement `Node&lt;Vec&lt;()&gt;&gt;: Sized`
</code></pre></div>



<a name="232282823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232282823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232282823">(Mar 29 2021 at 15:03)</a>:</h4>
<p>this happens because we have the following cycle:</p>



<a name="232282883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232282883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232282883">(Mar 29 2021 at 15:03)</a>:</h4>
<ul>
<li><code>Vec&lt;Node&lt;Vec&lt;()&gt;&gt;&gt;</code> require <code>Node&lt;Vec&lt;()&gt;&gt;</code> to be <code>Sized</code></li>
</ul>



<a name="232283010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232283010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232283010">(Mar 29 2021 at 15:04)</a>:</h4>
<ul>
<li>that requires <code>&lt;Vec&lt;()&gt; as CollectionFactory&lt;Node&lt;Vec&lt;()&gt;&gt;&gt;&gt;::Collection</code> to be <code>Sized</code></li>
</ul>



<a name="232283060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232283060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232283060">(Mar 29 2021 at 15:04)</a>:</h4>
<ul>
<li>which is <code>Vec&lt;Node&lt;Vec&lt;()&gt;&gt;&gt;</code></li>
</ul>



<a name="232283144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232283144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232283144">(Mar 29 2021 at 15:05)</a>:</h4>
<p>now, I think that if <code>Sized</code> were an auto trait, this would compile because of coinduction</p>



<a name="232283194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232283194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232283194">(Mar 29 2021 at 15:05)</a>:</h4>
<p>which leads me to ask, why is <code>Sized</code> not an auto trait?</p>



<a name="232283413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232283413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232283413">(Mar 29 2021 at 15:07)</a>:</h4>
<p>I can't easily think of why this might cause stuff to break, ignoring maybe the interaction with <code>PhantomData&lt;UnsizedType&gt;</code></p>



<a name="232285596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232285596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232285596">(Mar 29 2021 at 15:19)</a>:</h4>
<p>just changing <code>Sized</code> to an auto trait causes <code>str</code> to be sized</p>



<a name="232286081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232286081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232286081">(Mar 29 2021 at 15:22)</a>:</h4>
<p>so let's instead only change <code>fn coinductive_predicate</code></p>



<a name="232286931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232286931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232286931">(Mar 29 2021 at 15:28)</a>:</h4>
<p>that seems to work <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="232286961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232286961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232286961">(Mar 29 2021 at 15:28)</a>:</h4>
<p>now, is this (1) sound and (2) desired?</p>



<a name="232288288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232288288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232288288">(Mar 29 2021 at 15:37)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/83647">#83647</a></p>



<a name="232288497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232288497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232288497">(Mar 29 2021 at 15:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> if you have a few minutes, want to explain to me why that PR is unsound? ^^</p>



<a name="232292471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232292471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232292471">(Mar 29 2021 at 16:03)</a>:</h4>
<p>I can't immediately think of why <code>Sized</code> isn't an auto trait</p>



<a name="232292564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232292564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232292564">(Mar 29 2021 at 16:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait/near/232285596">said</a>:</p>
<blockquote>
<p>just changing <code>Sized</code> to an auto trait causes <code>str</code> to be sized</p>
</blockquote>
<p>This confuses me though</p>



<a name="232295052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232295052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232295052">(Mar 29 2021 at 16:22)</a>:</h4>
<p>If <code>Sized</code> determination is not coinductive, then why does this work?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">T</span><span class="p">(</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">);</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">assert_sized</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Sized</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">assert_sized</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Since <code>T: Sized</code> requires <code>Vec&lt;T&gt;: Sized</code> which requires <code>T: Sized</code></p>



<a name="232297001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297001">(Mar 29 2021 at 16:37)</a>:</h4>
<p>That's a lot of <code>T</code>s</p>



<a name="232297049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297049">(Mar 29 2021 at 16:37)</a>:</h4>
<div class="codehilite"><pre><span></span><code>struct Foo&lt;X&gt;(Vec&lt;X&gt;);
fn assert_sized&lt;T: Sized&gt;() {}
fn foo() { assert_sized::&lt;Foo&gt;() }
</code></pre></div>



<a name="232297210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297210">(Mar 29 2021 at 16:38)</a>:</h4>
<p>But <code>Vec</code> is always <code>Sized</code>, right?</p>



<a name="232297280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297280">(Mar 29 2021 at 16:39)</a>:</h4>
<p>That doesn't really require coinduction anyways</p>



<a name="232297388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297388">(Mar 29 2021 at 16:40)</a>:</h4>
<p>Coinduction occurs essentially when you get a cycle</p>



<a name="232297420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297420">(Mar 29 2021 at 16:40)</a>:</h4>
<p>And the logic of the cycle boils down to "This is true if it is true"</p>



<a name="232297542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297542">(Mar 29 2021 at 16:41)</a>:</h4>
<p>In <span class="user-mention" data-user-id="216206">@lcnr</span>'s example <code>Vec&lt;Node&lt;Vec&lt;()&gt;&gt;&gt;</code> requires <code>Node&lt;Vec&lt;()&gt;&gt;</code> which requires <code>Vec&lt;Node&lt;Vec&lt;()&gt;&gt;&gt;</code></p>



<a name="232297876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232297876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232297876">(Mar 29 2021 at 16:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span>'s example uses <code>Foo(Vec&lt;Foo&gt;)</code></p>



<a name="232298014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298014">(Mar 29 2021 at 16:45)</a>:</h4>
<p>Oh, I see</p>



<a name="232298026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298026">(Mar 29 2021 at 16:45)</a>:</h4>
<p>which afaict just works because of the way we implemented <code>adt_sized_constraints</code></p>



<a name="232298082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298082">(Mar 29 2021 at 16:45)</a>:</h4>
<p>The <code>T</code> in <code>struct T</code> is the type, not a typo missing param</p>



<a name="232298118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298118">(Mar 29 2021 at 16:46)</a>:</h4>
<p>It might just be that <code>T</code> isn't constructed</p>



<a name="232298281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298281">(Mar 29 2021 at 16:47)</a>:</h4>
<p>Hmm</p>



<a name="232298335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298335">(Mar 29 2021 at 16:47)</a>:</h4>
<p>nvm I see</p>



<a name="232298400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298400">(Mar 29 2021 at 16:47)</a>:</h4>
<p>because we skip params if they are bound by a predicate (maybe, kinda distracted rn)</p>



<a name="232298404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298404">(Mar 29 2021 at 16:47)</a>:</h4>
<p>I think it's just because <code>Vec</code> is sized regardless of <code>T</code></p>



<a name="232298557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298557">(Mar 29 2021 at 16:48)</a>:</h4>
<p>In <span class="user-mention" data-user-id="216206">@lcnr</span>'s example, <code>Node&lt;C&gt;</code> is only <code>Sized</code> if <code>C::Collection</code> is <code>Sized</code></p>



<a name="232298591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298591">(Mar 29 2021 at 16:48)</a>:</h4>
<p>but <code>Vec</code> is always <code>Sized</code>, because it's last field is <code>usize</code></p>



<a name="232298646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232298646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232298646">(Mar 29 2021 at 16:49)</a>:</h4>
<p>There's no cycle</p>



<a name="232300061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232300061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232300061">(Mar 29 2021 at 16:58)</a>:</h4>
<p>whoops sorry about the naming confusion</p>



<a name="232300469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232300469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232300469">(Mar 29 2021 at 17:00)</a>:</h4>
<blockquote>
<p>I think it's just because Vec is sized regardless of T</p>
</blockquote>
<p>I'm not sure exactly how this is handled, but given that const-eval has been using <code>[(); N]: Sized</code> as a stand-in for <code>WF(N)</code>, I think it is safe to say that <code>T: Sized</code> requires <code>WF(T)</code>. <code>Vec&lt;T&gt;: Sized</code> does not directly require <code>T: Sized</code> but <code>WF(Vec&lt;T&gt;)</code> requires <code>T: Sized</code></p>



<a name="232301065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301065">(Mar 29 2021 at 17:04)</a>:</h4>
<p>It does not</p>



<a name="232301096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301096">(Mar 29 2021 at 17:04)</a>:</h4>
<p>Err</p>



<a name="232301112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301112">(Mar 29 2021 at 17:04)</a>:</h4>
<p>Well, it might</p>



<a name="232301356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301356">(Mar 29 2021 at 17:06)</a>:</h4>
<p>I don't think so, actually</p>



<a name="232301438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301438">(Mar 29 2021 at 17:06)</a>:</h4>
<p>But I don't think it matters here</p>



<a name="232301786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232301786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232301786">(Mar 29 2021 at 17:09)</a>:</h4>
<p>I don't really have the time atm to think about this; busy at work</p>



<a name="232307083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232307083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232307083">(Mar 29 2021 at 17:43)</a>:</h4>
<p>One reason why it would make sense that <code>Sized</code> should be inductive, not coinductive, is that unlike things like <code>Send</code> that describe <em>a bad situation that should be avoided</em>, <code>Sized</code> describes <em>a property that must be derived</em>, namely the result of <code>sizeof</code>. The evaluation of <code>sizeof(T)</code> has to come to some expression that doesn't depend on <code>sizeof(T)</code>, so cycles aren't actually okay</p>



<a name="232307347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Sized%20is%20not%20an%20autotrait/near/232307347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Sized.20is.20not.20an.20autotrait.html#232307347">(Mar 29 2021 at 17:44)</a>:</h4>
<p>However, I think you are correct to hedge on the question of whether <code>Vec&lt;T&gt;: Sized</code> requires <code>T: Sized</code>, because <code>sizeof(Vec&lt;T&gt;)</code> doesn't depend on <code>sizeof(T)</code>. Somehow this is a weaker link in the chain, that makes this apparently circular definition work out</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>